﻿"use strict"; !
function (t, e, o) {
    function i(o) {
        var i = o,
        s = this,
        l = i.container;
        this.container = l,
        this._onScroll = i.onScroll || n,
        this._startPos = i.startPos || 0,
        this._endPos = i.endPos || -1e7,
        this.setEnd(i.endPos || -1e7),
        this._offsetTop = i.offsetTop || 0,
        this._originPos = parseInt(l.css("top")) || this._startPos || 0,
        this._originPosType = l.css("position") || "",
        this._bindEvents(),
        this._step = a ?
        function (t) {
            l.css({
                top: t + s._offsetTop + "px",
                position: "absolute"
            }),
            l.removeClass("sta_fixed")
        } : function () {
            l.css({
                position: "fixed",
                top: s._offsetTop + "px"
            })
        },
        t(e).bind("updateScroll",
        function (o, i) {
            s._startPos += i,
            t(e).trigger("scroll")
        })
    }
    var n = function () { },
    s = e.document,
    a = t.browser.isIE6;
    i.prototype = {
        constructor: i,
        play: function () {
            return this._isScrolling = !0,
            this
        },
        setEnd: function (t) {
            this._endPos = t + this.container.offset().height
        },
        stop: function () {
            return this.reset(),
            this._isScrolling = !1,
            this
        },
        reset: function (t) {
            var e = this._originPosType.toLowerCase();
            this._isPaused = !0,
            this.container.css({
                position: t ? "absolute" : e,
                top: t + "px" || "auto"
            })
        },
        _bindEvents: function () {
            var o = this;
            o._scrollHandler = function () {
                o._isScrolling && o._scroll()
            },
            t(e).bind("scroll", o._scrollHandler)
        },
        _scroll: function () {
            var t = s.documentElement.scrollTop || s.body.scrollTop,
            e = s.body.scrollHeight - this._endPos,
            o = this,
            i = t >= e;
            o._offsetTopMax = e,
            t > o._startPos && !i ? (o._isPaused = !1, o._step(t), o._onScroll.call(o, t)) : (i || (o._isPaused = !1), !o._isPaused && o.reset(i ? e : 0))
        }
    },
    t.fn["float"] = function (t, e, o, n) {
        return new i({
            container: this,
            startPos: t || this.offset().top,
            endPos: e,
            offsetTop: o,
            onScroll: n
        }).play()
    }
}(cQuery, window),
function (t) {
    function e() {
        function e(e, o, i, n) {
            this.map = e,
            this.hotelId = o,
            t("#" + this.hotelId).find(".icon_crown2").length ? (this.text = '<div class="map_mark"><span class="map_num">' + (i + 1) + '</span><div class="map_mark_inner"><div class="map_mark_price"><dfn>RMB</dfn><span class="b">{price}</span><span class="icon_crown"></span></div></div></div>', this.text = this.text.replace(/{price}/, n.price || 0)) : this.text = '<div class="map_mark"><span class="map_num">' + (i + 1) + '</span><div class="map_mark_inner"><div class="map_mark_price"><dfn>RMB</dfn><span class="b">' + n.price || "0</span></div></div></div>",
            this.latLng = new google.maps.LatLng(n.lat, n.lon),
            this.div = null,
            this.info = n,
            this.setMap(this.map)
        }
        var o = [],
        i = t("#sideMapHotel").html();
        return e.prototype = new google.maps.OverlayView,
        t.extend(e.prototype, {
            onAdd: function () {
                var e = document.createElement("div");
                e.innerHTML = this.text,
                e.style.position = "absolute",
                this.getPanes().overlayImage.appendChild(e),
                this.div = e,
                this.elem = t(e.firstChild),
                this.hotelItem = t("#" + this.hotelId).find(".searchresult_name"),
                this.bindEvents()
            },
            draw: function () {
                var t = this.getProjection().fromLatLngToDivPixel(this.latLng);
                this.div.style.left = t.x + "px",
                this.div.style.bottom = -t.y + "px"
            },
            onRemove: function () {
                this.unbindEvents(),
                this.div.parentNode.removeChild(this.div),
                this.div = null
            },
            bindEvents: function () {
                var e = this;
                this.onMouseover = function (n) {
                    e.elem.addClass("map_mark_hover"),
                    e.hotelItem.addClass("searchresult_name_hover"),
                    e.div.style.zIndex = "5";
                    var s = e.elem.offset();
                    if (!o[e.hotelId]) {
                        var a = document.createElement("div");
                        a.className = "side_map_hotel",
                        a.innerHTML = t.tmpl.render(i, e.info),
                        document.body.appendChild(a),
                        o[e.hotelId] = a
                    }
                    o[e.hotelId].style.cssText = "display:block; z-index:10; position:absolute; top:" + (s.top - 10) + "px; left:" + (s.left - 395) + "px;"
                },
                this.onMouseout = function (t) {
                    o[e.hotelId].style.display = "none",
                    e.elem.removeClass("map_mark_hover"),
                    e.hotelItem.removeClass("searchresult_name_hover"),
                    e.div.style.zIndex = ""
                },
                this.onClick = function (o) {
                    r && o.stop();
                    var i = document.forms[0],
                    n = t("#hidCheckInCheckOut").value(),
                    s = t("#hidTravleMoney").value(),
                    a = t("#hidSearchBox").value(),
                    l = t("#sorted").value(),
                    d = "",
                    h = e.hotelItem.find("a[detaildata-dopost]").length,
                    c = t("#" + e.hotelId).find('a[_type="suggest"]');
                    n && (d = n),
                    h && s && (d += s),
                    "T" == l && c.length <= 0 && (d += -1 !== d.indexOf("?") ? "&sorted=T" : "?sorted=T"),
                    a && (d += -1 !== d.indexOf("?") ? "&NoShowSearchBox=T" : "?NoShowSearchBox=T"),
                    i.action = e.info.url + d,
                    i.target = "_blank",
                    i.__VIEWSTATE && (i.__VIEWSTATE.name = "NOVIEWSTATE"),
                    i.submit()
                },
                t(this.div).bind("mouseover", this.onMouseover).bind("mouseout", this.onMouseout).bind("click", this.onClick)
            },
            unbindEvents: function () {
                t(this.div).unbind("mouseover", this.onMouseover).unbind("mouseout", this.onMouseout).unbind("click", this.onClick)
            }
        }),
        e
    }
    function o(t, e) {
        var o, i, n, s, a, l, r, d, h, c, p, u, m, f, v = [];
        for (var g in e) e[g].visible && v.push(e[g]);
        if (f = v.length) {
            if (1 === f) return void t.setCenter(v[0].latLng);
            for (h = v[0].latLng.lat(), d = v[1].latLng.lat(), r = v[0].latLng.lng(), l = v[1].latLng.lng(), o = v[1], m = 0; f > m; m++) s = v[m].latLng.lat(),
            a = v[m].latLng.lng(),
            h > s ? h = s : s > d && (d = s),
            r > a ? r = a : a > l && (l = a, o = v[m]);
            n = o.getProjection(),
            n && o.div && (i = n.fromLatLngToContainerPixel(o.latLng), i.x += o.div.offsetWidth, l = n.fromContainerPixelToLatLng(i).lng()),
            u = new google.maps.LatLng(h, r),
            p = new google.maps.LatLng(d, l),
            c = new google.maps.LatLngBounds(u, p),
            t.fitBounds(c)
        }
    }
    function i() {
        n(hotelDomesticConfig.hotelPositionJSON),
        t("#hotel_list_container").bind("mouseover",
        function (e) {
            var o = t(e.target || e.srcElement);
            if (o.hasClass("searchresult_name") || (o = o.parentNode()).hasClass("searchresult_name")) {
                var i = o.findParentNode("hotel_list_item").attr("id");
                o.addClass("searchresult_name_hover"),
                _[i] && _[i].div && (t(_[i].div).addClass("map_mark_hover"), _[i].div.style.zIndex = "5")
            }
        }).bind("mouseout",
        function (e) {
            var o = t(e.target || e.srcElement);
            if (o.hasClass("searchresult_name") || (o = o.parentNode()).hasClass("searchresult_name")) {
                var i = o.findParentNode("hotel_list_item").attr("id");
                o.removeClass("searchresult_name_hover"),
                _[i] && _[i].div && (t(_[i].div).removeClass("map_mark_hover"), _[i].div.style.zIndex = "")
            }
        }).bind("click",
        function (e) {
            var o = t(e.target || e.srcElement); ("more_hotel" == o.attr("id") || "more_hotel" == (o = o.parentNode()).attr("id")) && u.updateAll()
        })
    }
    function n(e) {
        u = window.observer = u || new t.ScrollObserver,
        u.unObserve(),
        v && f.unbind("change", v);
        for (var i in _) _.hasOwnProperty(i) && (_[i].setMap(null), delete _[i]);
        f = t(".hotel_list_item"),
        v = function (i, n) {
            if (!t(this).hasClass("hidden")) {
                var s = this.id,
                a = f.indexOf(this),
                l = e[a];
                if (n) if (_[s]) _[s].setMap(m);
                else {
                    l.price || 0;
                    _[s] = new p(m, s, a, l)
                } else _[s] && _[s].setMap(null);
                _[s].visible = n,
                setTimeout(function () {
                    o(m, _)
                },
                0)
            }
        },
        f.bind("change", v),
        u.observe(f),
        u.updateAll()
    }
    function s() {
        function e() {
            window.noHotel || t(".base_main").offset().height <= o.height ? d.stop() : d[s[0].checked ? "play" : "stop"]()
        }
        var o = h.offset(),
        i = o.top,
        n = t("body").offset().height - t(".page_box").offset().bottom;
        d = h["float"](i, n);
        var s = t("#isFloat");
        s.bind("click",
        function () {
            e()
        }),
        e()
    }
    function a() {
        if (hotelDomesticConfig && hotelDomesticConfig.query) {
            var e, o, i, n = hotelDomesticConfig.query;
            t.ajax("/international/tool/AjaxMettingInfo.ashx?CheckIn=" + n.checkIn + "&CheckOut=" + n.checkOut + "&CityId=" + n.cityId, {
                async: !0,
                cache: !0,
                onsuccess: function (n) {
                    t("#metting_place").html(n.responseText),
                    d && (o = d.container.offset(), e = y.offset(), i = o.bottom - e.bottom, i > 0 && d.container.css("top", o.top - i + "px"), d && d.setEnd(x.offset().height - e.bottom), showUnfoldSeo.init()),
                    t(".base_main").offset().height <= h.offset().height && d && d.stop()
                }
            })
        }
    }
    function l(e, o) {
        function i(t, e, o, i) {
            this.map = t,
            this.div = null,
            this.latLng = o,
            this.image = e,
            this.ready = i,
            this.setMap(this.map)
        }
        i.prototype = new google.maps.OverlayView,
        t.extend(i.prototype, {
            onAdd: function () {
                var t = document.createElement("div");
                t.style.position = "absolute",
                t.style.width = "33px",
                t.style.height = "47px",
                t.style.backgroundImage = this.image,
                t.style.zIndex = 3,
                t.style.cursor = "default",
                t.id = "mapCenterMark",
                this.getPanes().overlayImage.appendChild(t),
                this.div = t,
                this.ready.call(this)
            },
            draw: function () {
                var t = this.getProjection().fromLatLngToDivPixel(this.latLng);
                this.div.style.left = t.x - 17 + "px",
                this.div.style.bottom = -t.y - 10 + "px"
            },
            onRemove: function () {
                this.div.parentNode.removeChild(this.div),
                this.div = null
            }
        });
        var n = function () {
            function e(t, e, o, i) {
                this.map = t,
                this.text = e,
                this.latLng = i,
                this.className = o,
                this.div = null,
                this.setMap(t)
            }
            return e.prototype = new google.maps.OverlayView,
            t.extend(e.prototype, {
                onAdd: function () {
                    var t = document.createElement("div");
                    t.className = this.className,
                    t.innerHTML = this.text,
                    t.style.position = "absolute",
                    t.style.zIndex = "5",
                    t.style.display = "none",
                    this.getPanes().overlayMouseTarget.appendChild(t),
                    this.div = t
                },
                draw: function () { },
                onRemove: function () {
                    this.div.parentNode.removeChild(this.div),
                    this.div = null
                },
                show: function () {
                    var e = this.div;
                    e.style.display = "";
                    var o = this.getProjection(),
                    i = o.fromLatLngToDivPixel(this.latLng),
                    n = o.fromLatLngToDivPixel(this.map.getBounds().getNorthEast()),
                    s = t(e).offset();
                    e.style.bottom = -(i.y - 3) + "px",
                    i.x > n.x - s.width ? (e.style.left = i.x - s.width - 15 + "px", e.style.textAlign = "right") : (e.style.left = i.x + 18 + "px", e.style.textAlign = "")
                },
                hide: function () {
                    this.div.style.display = "none"
                }
            }),
            e
        }(),
        s = o.position.split("|"),
        a = new google.maps.LatLng(s[0], s[1]),
        l = "url(http://pic.c-ctrip.com/hotelinternational_seo/lp/hotel_pointer.png)",
        r = "url(http://pic.c-ctrip.com/hotelinternational_seo/lp/hotel_pointer_hover.png)",
        d = new n(e, o.landmarkName, "landmark_pop", a);
        g = new i(e, l, a,
        function () {
            var e = this.div;
            t(e).bind("mouseover",
            function () {
                e.style.backgroundImage = r,
                e.style.zIndex = 3,
                d.show()
            }).bind("mouseout",
            function () {
                d.hide(),
                e.style.backgroundImage = l,
                e.style.zIndex = 1
            })
        })
    }
    var r, d, h, c, p, u, m, f, v, g, _ = {},
    y = t(".page_box"),
    x = t("body"),
    w = function (e) {
        function o(t) {
            var e = t.getElementsByTagName("head")[0],
            o = e.insertBefore;
            e.insertBefore = function (t, i) {
                t.href && t.href.indexOf("fonts.googleapis.com") > -1 || o.call(e, t, i)
            }
        }
        var r = e.position,
        h = r.split("|"),
        p = new google.maps.LatLng(h[0], h[1]),
        u = {
            center: p,
            zoom: 15,
            scaleControl: !0,
            streetViewControl: !1,
            overviewMapControl: !0,
            mapTypeControl: !1,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        o(document),
        m = new google.maps.Map(c, u),
        i(),
        t.mapPlugin = {
            minimap: m,
            makeCenterLandmark: l
        },
        e.landmarkName && l(m, e),
        s(),
        1 != window.DestinationType || a(),
        window.GMap = {
            map: m,
            reload: n,
            floater: d,
            centerMark: g
        }
    };
    window.initGMap = function () {
        r = t.browser.isIE6,
        h = t("#side_inner"),
        p = e(),
        c = document.getElementById("mini_map"),
        r ? (h.css("width", "300px"), c.style.width = "298px") : t(window).bind("resize",
        function () {
            var t = window.innerWidth || document.documentElement.clientWidth || document.body.offsetWidth;
            1250 > t ? (h.css("width", "300px"), c.style.width = "298px") : (h.css("width", "380px"), c.style.width = "378px")
        }),
        r || t(window).trigger("resize"),
        w(hotelDomesticConfig.result),
        t(window).trigger("scroll")
    }
}(cQuery);